package graphics.fingerprint;

import android.graphics.Matrix;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class MoveListener implements OnTouchListener {

	private float image_x;// the x coordinate of image
	private float image_y;
	private float siy;
	private float six;
	private GestureDetector gd;
	
	public MoveListener(UserController userController, GestureDetector gd) {
		this.gd = gd;
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		float cx = event.getX();
		float cy = event.getY();
		PaintView view = (PaintView)v;
		
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			Log.d("Debug&Info", "*****************");
			Log.d("Debug&Info", "Action Down in MOVE");
			break;
		case MotionEvent.ACTION_MOVE:
			this.image_x += cx - this.six;
			this.image_y += cy - this.siy;
			Log.d("Debug&Info", "Action move in MOVE");
			break;
		}
		this.six = cx;
		this.siy = cy;
		
		Matrix im = view.getImageMatrix();
		im.setTranslate(this.image_x, this.image_y);
		
		view.invalidate();
		return gd.onTouchEvent(event);
	}
	
	public float getImage_x(){
		return this.image_x;
	}
	public float getImage_y(){
		return this.image_y;
	}
}
